package cn.fintecher.pangolin.service.business.model.request;

import cn.fintecher.pangolin.common.enums.CaseType;
import cn.fintecher.pangolin.common.enums.Relationship;
import cn.fintecher.pangolin.common.enums.Source;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

/**
 * @Auther: xiaqun
 * @Description: 新增联系人请求
 * @Date: 15:09 2019/9/16
 */

@Data
public class AddContactRequest {
    @ApiModelProperty(value = "案件ID")
    private String caseId;

    @ApiModelProperty(value = "证件号")
    private String certificateNo;

    @ApiModelProperty(value = "姓名")
    private String name;

    @ApiModelProperty(value = "关系")
    private String relation;

    @ApiModelProperty(value = "电话号码")
    private String phoneNo;

    @ApiModelProperty(value = "手机号码")
    private String mobile;

    @ApiModelProperty(value = "单位电话")
    private String workNo;

    @ApiModelProperty(value = "来源")
    private String source;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "委托方ID")
    private String principalId;

    @ApiModelProperty(value = "案件类型")
    private CaseType caseType;

    /**
     * 处理关系枚举
     */
    public Relationship processRelation() {
        if (StringUtils.isNotBlank(this.relation)) {
            switch (this.relation) {
                case "SELF":
                    return Relationship.SELF;
                case "SPOUSE":
                    return Relationship.SPOUSE;
                case "PARENT":
                    return Relationship.PARENT;
                case "CHILD":
                    return Relationship.CHILD;
                case "RELATIVES":
                    return Relationship.RELATIVES;
                case "COLLEUAGUE":
                    return Relationship.COLLEUAGUE;
                case "FRIEND":
                    return Relationship.FRIEND;
                case "OTHER":
                    return Relationship.OTHER;
                default:
                    return Relationship.OTHER;
            }
        } else {
            return null;
        }
    }

    /**
     * 处理来源枚举
     */
    public Source processSource() {
        if (StringUtils.isNotBlank(this.source)) {
            switch (this.source) {
                case "IMPORT":
                    return Source.IMPORT;
                case "REPAIRED":
                    return Source.REPAIRED;
                case "OTHER":
                    return Source.OTHER;
                default:
                    return Source.OTHER;
            }
        } else {
            return null;
        }
    }
}